from typing import Sequence

from app.controllers.base_controller import BaseController
from app.crud.menu_crud import MenuCRUD
from app.models import Menu
from app.models.base import IdType
from app.schemas.menu_schema import MenuCreate, MenuUpdate, MenuTreeOut, MenuOut
from app.schemas.result_schema import ResultFormat, ResultModel


class MenuController(BaseController[MenuCRUD,Menu,MenuCreate,MenuUpdate]):
    async def get_auth_menus(self, id: IdType) -> ResultModel[Sequence[Menu]]:
        result = await self.crud.get_auth_menus(id=id)
        return ResultFormat.result_list_model(data=result)

    async def sortable(self,id:IdType,target_id:IdType) -> ResultModel[bool]:
        result = await self.crud.sortable(id=id,target_id=target_id)
        return ResultFormat.result_bool(data=result, model_name="拖拽排序")